package org.alwayssuper.protocol.commons.transform.realtimev2025.enums;

/**
 * 充电状态枚举 (整车数据 0x01)
 * 基于 GB/T 32960.3-2025 标准
 * @author alwaysSuper
 */
public enum ChargingStatus {
    PARKED_CHARGING(0x01, "停车充电"),
    DRIVING_CHARGING(0x02, "行驶充电"),
    NOT_CHARGING(0x03, "未充电"),
    CHARGING_COMPLETE(0x04, "充电完成"),
    ABNORMAL(0xFE, "异常"),
    INVALID(0xFF, "无效");

    private final int code;
    private final String description;

    ChargingStatus(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static ChargingStatus fromCode(int code) {
        for (ChargingStatus status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        return INVALID;
    }

    @Override
    public String toString() {
        return String.format("ChargingStatus{code=0x%02X, description='%s'}", code, description);
    }
}